package com.kongyz;

/**
 * @author kongyz
 * @date 2018/7/3 21:14
 * @Description:
 */
public class Demo {
    public static void main(String[] args) {
        //添加状态
        Originator originator=new Originator();
        originator.setState("状态：#1");
        originator.setState("状态：#2");

        CareTaker careTaker=new CareTaker();
        careTaker.add(originator.saveStateToMemento());
        originator.setState("状态：#3");
        careTaker.add(originator.saveStateToMemento());
        originator.setState("状态：#4");

        System.out.println("当前状态："+originator.getState());

        originator.getStateFromMemento(careTaker.get(0));
        System.out.println("第一次保存的状态："+originator.getState());

        originator.getStateFromMemento(careTaker.get(1));
        System.out.println("第二次保存的状态："+originator.getState());

        originator.getStateFromMemento(careTaker.getLast());
        System.out.println("最后一次保存的状态："+originator.getState());

    }
}
